//# sourceURL=searchJobDetail.js
layui.element.on('tab(login-user-tabs)', function (layui_obj) {
    var custom_obj = $('#tabTitles')[0].children[layui_obj.index].tabCustomObj;
    var searchJobDetail_fn = {
        initRender: function () {
            cmsUtils.setContentTabHeight('searchJobDetailContent', 50);
            $('#searchJobDetail').attr('hasRender', true);
            if (custom_obj.id) {
                var url = '/inviteCompanyJob/detail/'+custom_obj.id;
                $.get(url, function (data) {
                    console.log(data);
                    searchJobDetail_fn.setFormData(data);
                });
            } else {
                cmsUtils.renderDynamicSelectionBox('/jobTitle/selectCombo/1','searchJobDetail-jobTitle','code','value');
                cmsUtils.renderDynamicSelectionBox('/cms/common/combo/result/edu','searchJobDetail-eduRequire','code','value');
            }
            layui.form.render(null, 'searchJobDetail-form');
        },
        setFormData: function (data) {
            cmsUtils.renderDynamicSelectionBox('/jobTitle/selectCombo/1','searchJobDetail-jobTitle','code','value');
            cmsUtils.renderDynamicSelectionBox('/cms/common/combo/result/edu','searchJobDetail-eduRequire','code','value');
            cmsUtils.formDataBind('searchJobDetail-form', data.data);
            layui.form.render(null, 'searchJobDetail-form');
        },
        getFormData: function (data) {
            data.inviteCompanyJobId = custom_obj.id;
            return data;
        },
        submitForm: function (post_params, action, index) {
            console.log(post_params);
            $.ajax({
                type: 'post',
                url: '/inviteRecord/invite',
                data: post_params,
                dataType: 'json',
                success: function (data) {
                    layer.close(index);
                    if (data.code == 200) {
                        switch (action) {
                            case 'close':
                                layui.element.tabDelete('login-user-tabs', 'tab-searchJobDetail');
                                custom_obj.list_fn.reload();
                                break;
                        }
                    } else {
                        layer.msg(data.msg ? data.msg : '保存失败', {anim: 6});
                    }
                }
            });
        }
    }
    if ($('#searchJobDetail')[0] && !$('#searchJobDetail').attr('hasRender')) {
        searchJobDetail_fn.initRender();
        // 设置页面高度
        $(window).resize(function() {
            cmsUtils.setContentTabHeight('searchJobDetailContent', 50);
        });
    }
    // 投递简历
    layui.form.on('submit(searchJobDetail-btn-invite)', function (data) {
        var msg = '确定投递简历？';
        layer.confirm(msg, {
            btn:['确定', '取消']
        }, function (index) {
            searchJobDetail_fn.submitForm(searchJobDetail_fn.getFormData(data.field), 'close', index);
        });
    });
});